﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Ylh.Data;
using Ylh.ElvModel;
using Ylh.Enums;

namespace Ylh.ElvBLL
{
    class NoteElvBLLcs
    {
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool InsertNote(string ConStr, Ylh.ElvModel.TbNote model)
        {
            return TbNote.InserObjedct(model, ConStr);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdateNote(string ConStr, Ylh.ElvModel.TbNote model)
        {
            return TbNote.Update(model, ConStr);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string ConStr, String NoteID)
        {
            TbNote note = new TbNote();
            OQLWhere where = new OQLWhere(note);
            where.AND(note, OperateType.等于, NoteID);
            return TbNote.Delete(where, ConStr);
        }


        /// <summary>
        /// 删除一条数据
        /// 设置为不可用,但是未删除数据
        /// </summary>
        public bool Deletestate(string ConStr, String NoteID)
        {
            TbNote note = new TbNote();
            note.state = false;
            note.NoteID = NoteID;
            return TbNote.Update(note, ConStr);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Ylh.ElvModel.TbNote GetModel(string ConStr, String NoteID)
        {
            SqlWhere where = new SqlWhere();
            where.Info = new TbNote() { NoteID = NoteID };
            DataTable dt = TbNote.Select(where, ConStr);
            List<TbNote> li = Pub.ConverDt2Model.DtToList<TbNote>(dt);
            if (li.Count == 0) return new TbNote();
            return li[0];
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataTable GetList(string ConStr, string strWhere)
        {
            SqlWhere where = new SqlWhere();
            where.StrSqlWhere = strWhere;
            DataTable dt = TbNote.Select(where, ConStr);
            return dt;
        }
    }
}
